// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.util;

import zombie.util.list.PZArrayUtil;

public final class PooledFloatArrayObject extends PooledObject {
    private static final Pool<PooledFloatArrayObject> s_pool = new Pool<>(PooledFloatArrayObject::new);
    private float[] m_array = PZArrayUtil.emptyFloatArray;

    public static PooledFloatArrayObject alloc(int count) {
        PooledFloatArrayObject pooledFloatArrayObject = s_pool.alloc();
        pooledFloatArrayObject.initCapacity(count);
        return pooledFloatArrayObject;
    }

    public static PooledFloatArrayObject toArray(PooledFloatArrayObject source) {
        if (source == null) {
            return null;
        } else {
            int _int = source.length();
            PooledFloatArrayObject pooledFloatArrayObject = alloc(_int);
            if (_int > 0) {
                System.arraycopy(source.array(), 0, pooledFloatArrayObject.array(), 0, _int);
            }

            return pooledFloatArrayObject;
        }
    }

    private void initCapacity(int _int) {
        if (this.m_array.length != _int) {
            this.m_array = new float[_int];
        }
    }

    public float[] array() {
        return this.m_array;
    }

    public float get(int idx) {
        return this.m_array[idx];
    }

    public void set(int idx, float val) {
        this.m_array[idx] = val;
    }

    public int length() {
        return this.m_array.length;
    }
}
